package com.symone.webcms.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.symone.webcms.mapper.CompanyMapper;
import com.symone.webcms.model.Company;
import com.symone.webcms.service.CompanyService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *　　
 *   @description : Company 服务实现类
 *   ---------------------------------
 * 	 @author Archer Chu
 *   @since 2018-11-18
 */
@Service
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements CompanyService {

    @Override
    public Page<Company> findPage(Page<Company> page, Wrapper<Company> entity) {
        List<Company> result = baseMapper.selectPage(page,entity);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<Company> findAll() {
        Wrapper<Company> ew = new EntityWrapper<Company>();
        ew.where("deleted=0");
        return baseMapper.selectList(ew);
    }

    @Override
    public int delete(String lang) {
        return baseMapper.deleteById(lang);
    }

    @Override
    public boolean deleteFlagById(String lang) {
        return baseMapper.deleteFlagById(lang);
    }

    @Override
    public int clear() {
        return baseMapper.delete(new EntityWrapper<Company>().eq("deleted" ,1));
    }

}
